package com.baoer.controller;


import com.baoer.service.QrCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class QrCodeController {

    @Autowired
    private QrCodeService  qrCodeService;

    /**
     * 生成二维码接口
     *
     * @param content 二维码内容
     * @return
     */
    @GetMapping("/generateQRCode")
    public String generateQRCode(@RequestParam String content) {
        try {
            // 将width、height固定为200，filePath固定为D:image/qr
            int width = 200;
            int height = 200;
            String filePath = "D:image/qr";

            qrCodeService.generateQRCode(content, width, height, filePath);
            return "二维码生成成功，保存路径为：" + filePath;
        } catch (Exception e) {
            e.printStackTrace();
            return "二维码生成失败：" + e.getMessage();
        }
    }
}